<template>
	<view class="content">
		<button class="size" v-for="(site,key) in typeList" @tap="handel(site,key)" :key="key">{{key}}</button>
		<view>{{value}}</view>
		<button class="size" @tap="createMessage">创建消息对象</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				typeList: {
					"TYPE_SMS": 1,
					"TYPE_MMS": 2,
					"TYPE_EMAIL": 3,
				},
				value: "",
				type: ""
			}
		},
		methods: {
			handel(site, key) {
				this.value = key + site;
				this.type = site;
			},
			createMessage() {
				let msg = plus.messaging.createMessage(this.type);
				if (this.type == 1) {
					msg.to = ['xxx'];
					msg.body = '🐷 🐷 你猜我是谁';
					plus.messaging.sendMessage(msg, function() {
						console.log("send=>", "success")
					}, function() {
						console.log("send=>", "fialed")
					});
					// 直接唤起发送短信键盘，发送内容回填，点击发送OK
				}
				if (this.type == 3) {
					console.log("66")
					msg.to = ['1552044904@qq.com'];
					msg.cc = ['1552044904@qq.com'];
					msg.bcc = ['1552044904@qq.com'];
					msg.subject = '测试邮件';
					msg.body = 'This is Pandora example test message';
					plus.messaging.sendMessage(msg, function() {
						console.log("Send success!");
					}, function(error) {
						console.log("Send failed!",error);
					});
				}

			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.size {
		margin: 30rpx 0;
	}
</style>
